package com.ca.project.core.Exception;

import com.ca.project.core.Respond.ResponseCode;
import lombok.Data;

/**
 * 自定义全局业务异常类
 *
 * @PACKAGE_NAME: com.ca.project.core.Exception
 * @NAME: BusinessException
 * @USER: ASUS
 * @DATE: 2023/8/25
 * @TIME: 上午 10:31
 **/
@Data
public class BusinessException extends RuntimeException {
    /**
     * 错误码
     */
    private Integer code;
    /**
     * 错误信息
     */
    private String message;

    /**
     * 业务异常
     * 构造方法
     *
     * @param responseCode
     */
    public BusinessException(ResponseCode responseCode) {
        this.code = responseCode.getCode();
        this.message = responseCode.getDesc();
    }

    /**
     * 业务异常
     *
     * @param code
     * @param message
     */
    public BusinessException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 业务异常
     *
     * @param message
     */
    public BusinessException(String message) {
        this.code = ResponseCode.ERROR.getCode();
        this.message = message;
    }

    /**
     * 业务异常
     */
    public BusinessException() {
        this.code = ResponseCode.ERROR.getCode();
        this.message = ResponseCode.ERROR_PARAM.getDesc();
    }

}
